'''
创建有字段意思的元组
并生成了一个类，就是POJO
'''
from collections import namedtuple

City = namedtuple('City', 'name country population coordinates')
tokyo = City('Tokyo', 'JP', 36, (35, 139))
print(tokyo)
print(tokyo.population)
print(tokyo.coordinates)
print(tokyo[1])

print()
print(City._fields)
LatLong = namedtuple('LatLong', 'lat long')
delhi_date = ('Delhi NCR', 'IN', 21, LatLong(28, 77))
delhi = City._make(delhi_date)
print(delhi._asdict())
for key, value in delhi._asdict().items():
    print(key + ':', value)

if __name__ == '__main__':
    print('done')
